﻿using System;
using NHibernate;
using NHibernate.Criterion;

namespace BooksOnline.Repositories.Base
{
    public class RepositoryBase<T> : NHibernateSessionProvider
    {
        public virtual T ById(Guid id)
        {
            return
                DetachedCriteria
                    .For<T>()
                    .Add(Restrictions.Eq("Id", id))
                    .GetExecutableCriteria(CurrentSession)
                    .UniqueResult<T>();
        }
    }
}